const defaultState = {
    count: 0
}

const changeState = (action) => {
    switch(action.type) {
        case 'increment' :
            defaultState.count++;
            break
        case 'decrement' :
            defaultState.count--;
            break
        default:
    }
}


//修改DOM操作！
const renderDom = () => {
    let countElement = document.querySelector('#count')
    countElement.innerHTML = defaultState.count
}

const dispatch = (action) => {
    changeState(action)
    renderDom()//重新渲染DOM
}

export {
    dispatch
}